<?php
/* @var $this ReviewsController */
/* @var $model Reviews */
?>

<?php
$this->breadcrumbs = array(
	'Reviews' => array('index'),
	$model->reviewId => array('view', 'id' => $model->reviewId),
	'Update',
);
?>

<div class="row-fluid">
    <div class="span12">
        <div class="grid simple">
			<div class="grid-title no-border">
				<h4>Поля с <span class="required"> * </span> обязательны для заполнения.</h4>
			</div>
			<div class="grid-body no-border">
				<?php
				$this->renderPartial('_form', array('model' => $model));
				$colors = array('success', 'info', 'warning', 'danger', 'success', 'info', 'warning', 'danger', 'success', 'info', 'warning', 'danger','success', 'info', 'warning', 'danger','success', 'info', 'warning', 'danger',);
				?>
			</div>
			<?php $sql = "SELECT \"ratingId\", \"ratingSum\" FROM {{_rev2rate}} WHERE \"reviewId\" = '$model->reviewId'"; ?>
			<?php $ratings = Yii::app()->db->getCommandBuilder()->createSqlCommand($sql)->queryAll(); ?>
			<?php foreach ($ratings as $key => $rating): ?>
				<?php
				$type = Ratingtype::model()->findByPk((int) $rating['ratingId']);
				echo $type['ratingTitle'];
				$percent = ((int) $rating['ratingSum']) / ((int) $type['ratingMax']) * 100;
				?>
				<div class="progress progress-<?php echo $colors[$key]; ?>">
					<div class="bar" style="width: <?php echo $percent; ?>%;" data-percentage="0%"></div>
				</div>
			<?php endforeach; ?>
        </div>	
    </div>
</div>